import { get, post, put, del } from "@/utils/request";
import { taskListRes, createTaskParams, geoListRes } from "./types";
enum URL {
	/* 获取解译任务列表 */
	getTaskList = "/task/task/list",
	/* 根据解译任务获取矢量信息 */
	getTaskDetail = "/task/geo/list",
	/* 新增解译任务 */
	addTask = "/task/task",
	/* 修改或重采任务矢量 */
	updateShp = "/task/geo",
	/* 新增任务矢量 */
	addShp = "/task/geo",
	/* 删除任务矢量 */
	delShp = "/task/geo/",
	// 解析本地shp文件
	shpGeo = "/task/task/shpGeom",
}
const getTaskList = async (taskType: number) =>
	get<taskListRes>({
		url: URL.getTaskList,
		params: { pageNum: 1, pageSize: 99999, taskType: taskType },
	});
const addTask = async (data: any) => post({ url: URL.addTask, data });
const delTask = async (taskId: number) =>
	del({
		url: URL.addTask + "/" + taskId,
	});
const getTaskDetail = async (taskId: number) =>
	get<geoListRes>({
		url: URL.getTaskDetail,
		params: {
			taskId,
		},
	});
// 修改或重采任务矢量
const updateShp = async (data: { id: string | number; geo: string }) => {
	put<any>({
		url: URL.updateShp,
		data,
	});
};
// 新增任务矢量
const addShp = async (data: { geo: string; interpretType: string; taskId: number }) => {
	post<any>({
		url: URL.addShp,
		data,
	});
};
// 删除任务矢量
const delShp = async (shpId: string | number) => {
	del({
		url: URL.delShp + "/" + shpId,
	});
};
// 解析本地shp文件
const shpGeo = async (formData: any) => {
	return post<any>({
		url: URL.shpGeo,
		data: formData,
	});
};
export { getTaskList, addTask, delTask, getTaskDetail, updateShp, addShp, delShp, shpGeo };
